var config = require('../../../utils/config.js');
var util = require('../../../utils/util');
var API_URL = config.API_URL;
var userInfo;
var getCommission = function (that) {
    my.httpRequest({
        url: API_URL.commission,
        data: {
            userId: userInfo.userId
        },
        method: 'POST',
        success: function (res) {
            that.setData({
                commission: res.data.data
            })
        },
        fail: function (res) {
            util.showNotice('网络错误')
        },
        complete: function (res) {
        }
    })
}
Page({
    data: {
        hidden: true
    },
    onLoad: function (options) {
        // 页面初始化 options为页面跳转所带来的参数
    },
    onReady: function () {

    },
    onShow: function () {
        var that = this;
        my.getStorage({
            key: 'user',
            success: function (res) {
                console.log(res);
                userInfo = res.data;
                my.httpRequest({
                    url: API_URL.account_status,
                    data: {
                        user_id: userInfo.userId
                    },
                    method: 'POST',
                    success: function (res) {
                        console.log(res)
                        that.setData({
                            hasPaymentPassword: res.data.data.hasPaymentPassword == 0 ? false : true
                        })
                    },
                    fail: function (res) { },
                    complete: function (res) { },
                })
            },
            fail: function (res) {
                my.alert({ content: res.errorMessage });
            }
        });

        getCommission(that)
    },
    // 我的银行卡跳转
    my_card: function () {
        let that = this;
        if (!that.data.hasPaymentPassword) {
            that.setData({
                hidden: false
            })
            return
        }
        my.navigateTo({
            url: "/pages/user/card/myCard/myCard?money_src_type=1"
        })
    },
})